(Plain-text protocol for development and usage with IRC. Binary, memory-optimized protocol to follow. This is not a real specification and will be subject to experimental changes for a longer period of time)

If data is said to be transmitted as 'binary data', it is actually supposed to be transmitted as ASCII being base64-encoded binary data.

state 0:

Alice sends '~~SDTP_SECURE_RANDOM_NUMBER_VERSION_0~~' to bob.

state 0:

Bob acknowledges the initialization from Alice by sending 'continue'.

state 1:

Alice sends the range of the random number as two unsigned 16 bit integers in Network Byte Order resulting in 4 bytes:

[2 byte] = minimum value
[2 byte] = maximum value

state 1:

Bob acknowledges the received range from Alice by sending 'continue'. The client prints the range as two decimal integers.

state 2:

Alice generates 16 bytes of entropy (local_entropy) and calculates the 32-byte hash of it (local_hash). The hash is transmitted to Bob.

state 2:

Bob receives the hash from Alice (remote_hash) and likewise generates his entropy (local_entropy) and generates his local_hash which is transmitted to Alice.

state 3:

Alice receives the hash from Bob (remote_hash) and reveals her local_entropy to Bob.

state 3:

Bob likewise reveals his local_entropy to Alice.

Everything from now on happens offline:

state 4:

Alice and Bob hash the remote_entropy to chk_hash and compare the value to the remote_hash.

If it is equal, they take the last 4 bytes of each entropy and XOR every byte and cast it to an unsigned 32 bit integer which is assumed to be in network byte order.
They then mod it to (maximum_value - minimum_value) and add minimum_value. The result is the random number.

If it is unequal, the client tells the user that the secure random number generation failed. The error message may not imply that malicious behavior took place, although it should inform about the possibility of that as well as possible technical errors.